# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer:
pkgname=drone
pkgver=1.7.0
pkgrel=1
pkgdesc="Container-Native, Continuous Delivery Platform"
url="https://drone.io/"
arch="all"
license="custom"
makedepends="go"
options="!check"
_commands="
	$pkgname-agent:_pkg
	$pkgname-controller:_pkg
	$pkgname-server:_pkg
	"
subpackages="
	$_commands
	$pkgname-doc
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/drone/drone/archive/v$pkgver.tar.gz"

export GOPATH="$srcdir"

build() {
	for pkg in $_commands; do
		GO111MODULE=on go build -o bin/${pkg%%:*} ./cmd/${pkg%%:*}
	done
}

package() {
	install -Dm 644 "$builddir"/LICENSE \
		"$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

_pkg() {
	pkgdesc="$pkgdesc ($subpkgname)"
	install_if="$pkgname"
	install -Dm775 "$builddir"/bin/$subpkgname \
		"$subpkgdir"/usr/bin/$subpkgname
}

cleanup_srcdir() {
	go clean -modcache
	default_cleanup_srcdir
}

sha512sums="db2dd8b1a8ee8d98d42ba9e1cecc85ee979b56ab1098435b6298fd90c75e73d6b5b30824e87915c1ad405dbdcb1db18f8834fb7985a2621c64dde47806e29f7f  drone-1.7.0.tar.gz"
